import sqlite3
from math import ceil

class Weapon:
   def __init__(self, name, arc):
      db = sqlite3.connect('blitz.db')
      c = db.cursor()
      c.execute('select * from weapons where code="%s"' % name)
      q = c.fetchone()
      c.close()
      db.close()

      self.arc = arc
      self.name = q[0]
      self.acc = q[1]
      maxRange = q[2]
      self.rangeband = []
      if maxRange != 1:
         self.rangeband.append(int(ceil(maxRange / 16.0)))
         self.rangeband.append(int(maxRange / 8.0))
         self.rangeband.append(int(maxRange / 4.0))
         self.rangeband.append(int(maxRange / 2.0))
      self.rangeband.append(maxRange)
      self.damage = q[3]
      self.rof = q[4]
      self.ae = q[5]
      self.indirect = q[6]
      self.hasNote = q[7]
      self.code = q[8]

      return